< previous page page_219 next page >

Page 219
    RASCS_AuthAck
    RASCS_ReAuthenticate
    RASCS_Authenticated
    RASCS_PrepareForCallback
    RASCS_WaitForModemReset
    RASCS_WaitForCallback
    RASCS_Projected
    RASCS_StartAuthentication
    RASCS_CallbackComplete
    RASCS_LogonNetwork
    RASCS_SubEntryConnected
    RASCS_SubEntryDisconnected
    RASCS_Interactive = RASCS_PAUSED
    RASCS_RetryAuthentication
    RASCS_CallbackSetByCaller
    RASCS_PasswordExpired
    RASCS_Connected = RASCS DONE
    RASCS_Disconnected
End Enum
Do you see it? The code is virtually identical, with only minor changes due to the language syntax.
This illustrates an important point: Languages tend to fall into certain classifications. Both Visual Basic and C belong to the class of block-structured languages. They tend to have a great many similarities. One of the most important things that any Visual Basic programmer needs to learn when dealing with the Microsoft documentation is to realize that much of what you already know is directly applicable. A little bit of guesswork and experimentation can solve most API-related problems.
Which brings us to the next problemthe callback function. If you got the enumeration correct and were able to run the application, the result was probably an immediate memory exception. Why?
Let's look again at the RasDialFunc description:
VOID WINAPI RasDialFunc(
    UINT unMsg, // type of event that has occurred
    RASCONNSTATE rasconnstate, // connection state about to be entered
    DWORD dwError // error that may have occurred
   );
You may not be familiar with callback functions per se, but you should be quite familiar with what an API function would require in this case. Imagine then, for a moment, that this was an exported function. How would you declare it? The API

 
< previous page page_219 next page >